package product.controller;

import com.feign.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import product.domain.Category;
import product.service.CategoryService;
import product.service.TempService;
import product.votmp.item.SkuInfoVo;
import product.votmp.list.ListVo;
import product.votmp.list.SearchParamsVo;

import java.util.List;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("product/temp")
public class TmpController {

    @Autowired
    private TempService tempService;

    @Autowired
    private CategoryService categoryService;

    @PostMapping("list")
    public R reqGetSearchInfo(@RequestBody SearchParamsVo searchParamsVo) {
        ListVo listVo = tempService.getSearchInfo(searchParamsVo);
        return R.ok().put("data", listVo);
    }

    @GetMapping("item/{skuId}")
    public R item(@PathVariable Long skuId) throws ExecutionException, InterruptedException {
        SkuInfoVo skuInfo = tempService.getBySkuId(skuId);
        return R.ok().put("data", skuInfo);
    }

    /**
     * 查询树形排序好好的节点
     *
     * @return
     */
    @GetMapping("categoryList")
    public R getCategoryList() {
        List<Category> categoryList = categoryService.findAllCategoryList();
        return R.ok().put("categoryList", categoryList);
    }


}
